[OpenVINO backend] Support for numpy.eigh #22363
[OpenVINO backend] Support for numpy.eigh #22363andersendsa wants to merge 3 commits intokeras-team:masterfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces support for the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds support for numpy.eigh to the OpenVINO backend by providing a NumPy-based implementation for eager tensors. The approach is sound, and the error handling for symbolic tensors is appropriate. My review includes a suggestion to ensure the return type is consistent with other backend operations by wrapping the output in OpenVINOKerasTensor instances, which is crucial for maintaining the backend's abstraction layer.
| return ( | ||
| ov_opset.constant(w).output(0), | ||
| ov_opset.constant(v).output(0), | ||
| ) |
There was a problem hiding this comment.
For consistency with other operations in the OpenVINO backend (e.g., inv, norm), this function should return a tuple of OpenVINOKerasTensor instances instead of raw ov.Output objects. This ensures that the results remain within the Keras backend tensor abstraction, allowing subsequent Keras operations to work correctly on them.
| return ( | |
| ov_opset.constant(w).output(0), | |
| ov_opset.constant(v).output(0), | |
| ) | |
| return ( | |
| OpenVINOKerasTensor(ov_opset.constant(w).output(0)), | |
| OpenVINOKerasTensor(ov_opset.constant(v).output(0)), | |
| ) |
References
- According to the Keras API design guidelines, objects that perform similar functions should have consistent APIs. Other linear algebra functions in this backend return
OpenVINOKerasTensorinstances, andeighshould follow this pattern for consistency. (link)
There was a problem hiding this comment.
Please address the gemini reviews given here.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #22363 +/- ##
==========================================
+ Coverage 82.95% 83.01% +0.05%
==========================================
Files 595 596 +1
Lines 66040 66702 +662
Branches 10305 10383 +78
==========================================
+ Hits 54785 55373 +588
- Misses 8639 8692 +53
- Partials 2616 2637 +21
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
hi @hertschuh this pr passes all the tests and is ready for review |
| return ( | ||
| ov_opset.constant(w).output(0), | ||
| ov_opset.constant(v).output(0), | ||
| ) |
There was a problem hiding this comment.
Please address the gemini reviews given here.
| @@ -348,7 +348,6 @@ LayerTest::test_stateless_call | |||
| LinalgOpsCorrectnessTest::test_cholesky | |||
| LinalgOpsCorrectnessTest::test_det | |||
| LinalgOpsCorrectnessTest::test_eig | |||
There was a problem hiding this comment.
Could we implement eig as well in this PR?
There was a problem hiding this comment.
sure will do it
keras/src/backend/openvino/linalg.py
Outdated
|
|
||
| a = convert_to_tensor(a) | ||
| try: | ||
| a_np = convert_to_numpy(a) |
There was a problem hiding this comment.
We do the implementations using OpenVINO opsets specifically
There was a problem hiding this comment.
will change it asap
d8a36fa to
bd650a0
Compare
|
hi @hertschuh i have done the changes and the pr passes all the tests and is ready for review |
| a_evaluated = OpenVINOKerasTensor(a_ov) | ||
| try: | ||
| a_np = convert_to_numpy(a_evaluated) | ||
| except Exception as e: | ||
| raise ValueError( | ||
| "eigh is only supported for static eager tensors " | ||
| "in the openvino backend. Received a dynamic or symbolic tensor." | ||
| ) from e | ||
|
|
There was a problem hiding this comment.
I don't understand why this would be needed. Also, we don't want numpy on the execution path, otherwise something that could run on GPU would run on CPU with NumPy instead of OV.
Details :
Implement numpy.eigh operation for the OpenVINO backend.
Closes issue : openvinotoolkit/openvino#34520